class InvoicePdf < Prawn::Document
  
  def initialize(order, view)
    super()
    @order = order
    @view = view
    text "Students Book Shop - Invoice"
    
    move_down 30
    
    text "Students Book Shop AG"
    text "Studentengasse 3"
    text "3011 Bern"
    text "+41 79 123 456"
    move_down 5
    text @order.name, :align => :right
    text @order.address, :align => :right
    text @order.email, :align => :right
    
    invoiceinfo = [["Product", "Quantity", "Price"]]
    
    i=1
    @order.line_items.each do |item|
      invoiceinfo[i] = [item.product.title, item.quantity, item.total_price]
      i=i+1
    end
    
    invoiceinfo[i] = ["Total", "", @order.total_price]
    

    move_down 130
    text '  Invoice Receipt', style: :bold
    move_down 10
    
    table invoiceinfo do
      column(0).width = 420
      column(1..2).width = 60
    end
        

  end
 
end